<?php
class Bean {
	public $id;
	
	public function __construct() {
		$this->id = -1;
	}
	
	public function get_id() {
		return $this->id;
	}
	
	public function set_id($id) {
		$this->id = $id;
	}
	
	public function setar_atributos($array) {
		foreach ($array as $atributo => $valor) {
			$this->$atributo = $valor;
		}
	}
	
	public function preparar_pra_mysql() {
		foreach ($this as $atributo => $valor) {
			if (gettype($valor) == "boolean") {
				if ($valor) {
					$this->$atributo = "TRUE";
				}
				else {
					$this->$atributo = "FALSE";
				}
			}
			elseif (gettype($valor) != "object") {
				$this->$atributo = mysql_real_escape_string($valor);
			}
		}
	}
}
?>